import { list, Enable, cash, edit, download,orderreject,orderconfirm,takeDownCheck,takedownconfirm } from "@/api/userlist";
import { resetRouter } from "@/router";
const getDefaultState = () => {
  return {
    token: 1,
    name: "",
    avatar: "",
    userId: "",
    userType: "",
  };
};

const state = getDefaultState();

const mutations = {

};

const actions = {
  // user login
  list({ commit }, data) {
    return new Promise((resolve, reject) => {
      list(data)
        .then((res) => {
          console.log(res);
          resolve(res);
        }).catch((error) => {
          reject(error);
        });
    });
  },
  Enable({ commit }, data) {
    return new Promise((resolve, reject) => {
      Enable(data)
        .then((res) => {
          console.log(res);
          resolve(res);
        }).catch((error) => {
       
          reject(error);
        });
    });
  },
  cash({ commit }, data) {
    // /admin/user/v1/cash
    return new Promise((resolve, reject) => {
      cash(data)
        .then((res) => {
          console.log(res);
          resolve(res);
        }).catch((error) => {
       
          reject(error);
        });
    });
  },
  edit({ commit }, data) {
    return new Promise((resolve, reject) => {
      edit(data)
        .then((res) => {
          console.log(res);
          resolve(res);
        }).catch((error) => {
       
          reject(error);
        });
    });
  },
  download({ commit }, data) {
    return new Promise((resolve, reject) => {
      download(data)
        .then((res) => {
          resolve(res);
        }).catch((error) => {
       
          reject(error);
        });
    });
  },
  orderreject({ commit }, data) { 
    return new Promise((resolve, reject) => {
      orderreject(data)
        .then((res) => {
          resolve(res);
        }).catch((error) => {
       
          reject(error);
        });
    });
  },
  orderconfirm({ commit }, data) { 
    return new Promise((resolve, reject) => {
      orderconfirm(data)
        .then((res) => {
          resolve(res);
        }).catch((error) => {
          console.log(error);
       
          reject(error);
        });
    });
  },
  takeDownCheck({commit},data){
    // 校验
    return new Promise((resolve, reject) => {
      takeDownCheck(data)
        .then((res) => {
          resolve(res);
        }).catch((error) => {
       
          reject(error);
        });
    });
  },
  takedownconfirm({commit},data){
    return new Promise((resolve, reject) => {
      takedownconfirm(data)
        .then((res) => {
          resolve(res);
        }).catch((error) => {
       
          reject(error);
        });
    });
  }
  // /admin/release_order/v1/take-down-confirm
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
